clear

load qestimates
load qinference
load data
load sigma_inference
[c,i]=unique(competitionid);
Nmergers=sum(totmergers(i,1));
inf2=inf;

EST = zeros(68,7);
for zz=1:68

w=load('competitions.mat');
x=load('data.mat');
COMP=w.comp_list(zz,1);
competitionid=x.competitionid;
nsubs = size(x.maxscore(competitionid==COMP,1),1);
load(sprintf('Estimates/%s_%02d.mat', 'estimates',COMP))
format shortg;
inf2(zz,1)=inf(zz,1)*(nsubs);
inf2(zz,2)=inf(zz,2)*(nsubs);
EST(zz,:)=[sigmaT; max(0.0001,inf2(zz,1)) ;max(0.0001,sigmaS);max(0.0001,inf2(zz,2));beta0(zz,1); se0(zz,1) ;nsubs]';
end
zz=1
rowLabels={'$\beta_1$ ($q$)','$\beta_2$ ($q$)'};
colLabels={'Estimate','SE'};
format shortg;
ESTcommon = [beta1(zz,1),se1(zz,1);beta1tr(zz,1),se1tr(zz,1)];
ESTcommon=round(ESTcommon*10000)/10000;
format shortG
matrix2latex(ESTcommon,'Output/Table5A.tex','rowLabels', rowLabels,'columnLabels', colLabels,'alignment', 'c','format','%-6.4f')

%EST(:,1:end-1)=round(EST(:,1:end-1)*1000)/1000;
rowLabels={'Wikipedias Participation Challenge','Allstate Claim Prediction Challenge','dunnhumbys Shopper Challenge','Give Me Some Credit','Dont Get Kicked!','CHALEARN Gesture Challenge','What Do You Know?','Photo Quality Prediction','The Hewlett Foundation: Automated Essay Scoring','KDD Cup 2012, Track 2','Predicting a Biological Response','Online Product Sales','Belkin Energy Disaggregation Competition','Merck Molecular Activity Challenge','Predict Closed Questions on Stack Overflow','Job Salary Prediction','The Marinexplore and Cornell University Whale Detection Challenge','KDD Cup 2013 - Author-Paper Identification Challenge (Track 1)','KDD Cup 2013 - Author Disambiguation Challenge (Track 2)','Packing Santas Sleigh','Higgs Boson Machine Learning Challenge','Liberty Mutual Group - Fire Peril Loss Cost','Helping Santas Helpers','March Machine Learning Mania 2015','Otto Group Product Classification Challenge','ICDM 2015: Drawbridge Cross-Device Connections','Caterpillar Tube Pricing','Liberty Mutual Group: Property Inspection Prediction','Springleaf Marketing Response','Truly Native?','The Allen AI Science Challenge','Santas Stolen Sleigh','Second Annual Data Science Bowl','BNP Paribas Cardif Claims Management','Home Depot Product Search Relevance','Santander Customer Satisfaction','Expedia Hotel Recommendations','Ultrasound Nerve Segmentation','Draper Satellite Image Chronology','Predicting Red Hat Business Value','TalkingData Mobile User Demographics','Outbrain Click Prediction','The Nature Conservancy Fisheries Monitoring','Dstl Satellite Imagery Feature Detection','Intel \& MobileODT Cervical Cancer Screening','Cdiscounts Image Classification Challenge','Recruit Restaurant Visitor Forecasting','Statoil/C-CORE Iceberg Classifier Challenge','TrackML Particle Tracking Challenge','Santa Gift Matching Challenge','Google Cloud \& NCAA ML Competition 2018-Mens','Google Cloud \& NCAA ML Competition 2018-Womens','Google AI Open Images - Object Detection Track','Google AI Open Images - Visual Relationship Track','Airbus Ship Detection Challenge','Peking University/Baidu - Autonomous Driving','TGS Salt Identification Challenge','Quick, Draw! Doodle Recognition Challenge','RSNA Pneumonia Detection Challenge','Human Protein Atlas Image Classification','Traveling Santa 2018 - Prime Paths','Google Cloud \& NCAA ML Competition 2019-Mens','Instant Gratification','Predicting Molecular Properties','SIIM-ACR Pneumothorax Segmentation','APTOS 2019 Blindness Detection','Lyft 3D Object Detection for Autonomous Vehicles','Santas Workshop Tour 2019'};
colLabels = {'$\sigma^{\text{team}}$','SE','$\sigma^{\text{sub}}$','SE','$\beta_0$ ($q$)','SE', '$N$'};
format shortG
%EST=round(10000*EST)/10000
matrix2latex(EST,'Output/TableA4.tex','rowLabels', rowLabels,'columnLabels', colLabels,'alignment', 'c','format','%-6.4f')

rowLabels={'TGS Salt Identification Challenge','Quick, Draw! Doodle Recognition Challenge','RSNA Pneumonia Detection Challenge','Human Protein Atlas Image Classification','Traveling Santa 2018 - Prime Paths','Google Cloud \& NCAA ML Competition 2019-Mens','Instant Gratification','Predicting Molecular Properties','SIIM-ACR Pneumothorax Segmentation','Lyft 3D Object Detection for Autonomous Vehicles'};
format shortg;
EST=EST(1:size(rowLabels,2),:);
matrix2latex(EST,'Output/Table5B.tex','rowLabels', rowLabels,'columnLabels', colLabels,'alignment', 'c','format','%-6.4f')
